#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int leap_year(int n)
{
	if (n % 400 == 0)
		return 1;
	else if (n % 100 == 0)
		return 0;
	else if (n % 4 == 0)
		return 1;
	else
		return 0;
}
int main()
{
	int day[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int mon = 0;
	int year = 0;
	scanf("%d%d", &year, &mon);
	if (leap_year(year) && mon == 2)
		printf("%d\n", day[mon] + 1);
	else
		printf("%d\n", day[mon]);
	return 0;
}